package dbschema

import (
	"git.sr.ht/~mil/mobsql/sqlgen"
)

// Internal tracking table to keep track of the timestamp/checksum/n_rows
// loaded for each GTFS table/source combination.
var tableInternalSystemTracking = sqlgen.TableSpec{
	Table:     "_mobsql",
	UniqueSet: []string{"source", "source_pair", "tbl"},
	Columns: []sqlgen.LoadColumn{
		sqlgen.LoadColumn{Column: "source", DType: sqlgen.DTypeInt, Required: true},
		sqlgen.LoadColumn{Column: "source_pair", DType: sqlgen.DTypeInt, Required: false},
		sqlgen.LoadColumn{Column: "tbl", DType: sqlgen.DTypeText, Required: true},
		sqlgen.LoadColumn{Column: "checksum", DType: sqlgen.DTypeText, Required: true},
		sqlgen.LoadColumn{Column: "n_rows", DType: sqlgen.DTypeInt, Required: true},
		sqlgen.LoadColumn{Column: "timestamp", DType: sqlgen.DTypeInt, Required: true},
	},
}

// Internal tracking table that is a direct import from the Mobility
// Database Catalog; this is updated each time mobsql's InitializeApp
// is rerun (e.g. every mobsql go library call or CLI invokation).
var tableInternalMDB = sqlgen.TableSpec{
	Table:     "_mdb",
	UniqueSet: []string{"mdb_source_id"},
	Columns: []sqlgen.LoadColumn{
		{Column: "data_type", DType: sqlgen.DTypeText, Required: true},
		{Column: "location.bounding_box.minimum_latitude", DType: sqlgen.DTypeReal},
		{Column: "location.bounding_box.minimum_longitude", DType: sqlgen.DTypeReal},
		{Column: "location.bounding_box.maximum_latitude", DType: sqlgen.DTypeReal},
		{Column: "location.bounding_box.maximum_longitude", DType: sqlgen.DTypeReal},
		{Column: "location.country_code", DType: sqlgen.DTypeText},
		{Column: "location.subdivision_name", DType: sqlgen.DTypeText},
		{Column: "location.municipality", DType: sqlgen.DTypeText},
		{Column: "urls.latest", DType: sqlgen.DTypeText, Required: true},
		{Column: "mdb_source_id", DType: sqlgen.DTypeInt, Required: true},
		{Column: "name", DType: sqlgen.DTypeText},
		{Column: "status", DType: sqlgen.DTypeText},
		{Column: "provider", DType: sqlgen.DTypeText, Required: true},
	},
}
